#include <stdio.h>

void swapVal(int *nums, int *numSize)
{
    int swap = *nums;
    *nums = *numSize;
    *numSize = swap;
}

void InsertSort(int *nums, int numSize)
{
    int backNum = 0;
    for (int idx = 0; idx < numSize; idx++)
    {
        backNum = nums[idx];
        int prevIdx = idx - 1;
        while (nums[prevIdx] > backNum && prevIdx >= 0)
        {
            nums[prevIdx + 1] = nums[prevIdx];
            prevIdx--;
        }
        // 退出循坏
        nums[prevIdx + 1] = backNum;
    }
}

void printArray(int *nums, int numSize)
{
    for (int i = 0; i < numSize; i++)
    {
        printf("%d ", nums[i]);
    }
    printf("\n");
}

int main()
{
    int str[6] = {29, 16, 26, 24, 0, 6};
    int length = sizeof(str) / sizeof(str[0]);
    InsertSort(str, length);
    printArray(str, length);
    return 0;
}